package com.qf.auth.api;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.qf.auth.service.CheckCodeService;
import com.qf.common.bean.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短信验证码业务
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/auth/checkcode")
public class CheckCodeController {

    @Autowired
    private CheckCodeService checkCodeService;


    /**
     * 发送短信验证码
     * @param phone
     * @return
     */
    @PostMapping("/send")
    public R<Boolean> send(String phone) throws Exception {
        if (StringUtils.isEmpty(phone)) {
            return R.fail("手机号不能为空!");
        }
        R<Boolean> r = checkCodeService.send(phone);
        return r;
    }
}
